<template>
	<div class="app-container">
		<div class="policyupper3c">
			<div class="p-top">
				<nextnav :navnum='navnum'></nextnav>
			</div>
			<div class="p-detail">
				<p>{{info.batchName}}<span class="add" v-if='info.isReward'>奖励</span></p>
				<div class="d-box">
					<p>
						<span>保险公司：</span><span class="d-setc">{{info.insuranceName}}</span>&nbsp;&nbsp;
						<span>有效日期：</span>
						<span class="d-setc">{{info.effectiveDate}} 到 </span>
						<span class="d-setc" v-if="info.expiryDate != ''">{{info.expiryDate}}</span>
						<span class="d-setc" v-if="info.expiryDate == ''">不限</span>&nbsp;&nbsp;
						<span>匹配日期类型：</span><span class="d-setc">{{info.matchDateType}}</span>&nbsp;&nbsp;
					</p>
					<p>
						<span>适用工号：</span><span class="d-setc" v-for='item in info.staffNames'>
						<span class="d-setc isF">&nbsp;&nbsp;|&nbsp;&nbsp;</span>{{item.insuranceName}}-{{item.staffAccount}}({{item.describe}})</span>
					</p>
				</div>
			</div>
			<div class="p-list">
				<table class="util-table">
					<tr>
						<th rowspan="2" width="455">政策备注信息</th>
						<th rowspan="2" width="100">上/下游</th>
						<th colspan="2" width="200">交强险</th>
						<th colspan="2" width="200">商业险</th>
						<th rowspan="2" width="150">操作</th>
					</tr>
					<tr>
						<th width="100">佣金</th>
						<th width="100">奖励</th>
						<th width="100">佣金</th>
						<th width="100">奖励</th>
					</tr>
					<tr v-for='item in policylist'>
						<td>{{item.remarks}}</td>
						<td class="setc">
							<div>
								<span class="setr">上游</span>
								<span class="setg">下游（业务通用）</span>
								<span class="setg" v-for='i in item.extends' v-if='item.extends.length != 0'>
								<span v-if='i.extendTypes==0'>下游（{{i.count}}个政策级别）</span>
								<span v-if='i.extendTypes==1'>下游（{{i.count}}个组织）</span>
								<span v-if='i.extendTypes==2'>下游（{{i.count}}个用户）</span>
								</span>
							</div>
						</td>
						<td class="setc">
							<div>
							<span class="spanset">{{item.upperBrokerageTraffic}}%</span>
							<div class="setH">
								<input type="text" class="inputset" v-bind:class="{'setred':item.traffic || item.traffic1}" v-model='item.lowerBrokerageTraffic' @blur='getTest(item)' @change='getchange(item)'/><span>&nbsp;%</span>
							</div>
							<div class="setH" v-for='i in item.extends' v-if='item.extends.length != 0'>
								<input type="text" class="inputset" v-bind:class="{'setred':i.traffic || i.traffic1}" v-model='i.lowerBrokerageTraffic' @blur='getTest(i)' @change='getchange(i)'/><span>&nbsp;%</span>
							</div>
							</div>
						</td>
						<td class="setc">
							<div>
							<span class="spanset">{{item.upperRewardTraffic}}%</span>
							<div class="setH">
								<input type="text" class="inputset" v-bind:class="{'setred':item.traffic || item.traffic2}" v-model='item.lowerRewardTraffic' @blur='getTest(item)' @change='getchange(item)'/><span>&nbsp;%</span>
							</div>
							<div class="setH" v-for='i in item.extends' v-if='item.extends.length != 0'>
								<input type="text" class="inputset" v-bind:class="{'setred':i.traffic || i.traffic2}" v-model='i.lowerRewardTraffic' @blur='getTest(i)' @change='getchange(i)'/><span>&nbsp;%</span>
							</div>
							</div>
						</td>
						<td class="setc">
							<div>
							<span class="spanset">{{item.upperBrokerageBusiness}}%</span>
							<div class="setH">
								<input type="text" class="inputset" v-bind:class="{'setred':item.business || item.business1}" v-model='item.lowerBrokerageBusiness' @blur='getTest(item)' @change='getchange(item)'/><span>&nbsp;%</span>
							</div>
							<div class="setH" v-for='i in item.extends' v-if='item.extends.length != 0'>
								<input type="text" class="inputset" v-bind:class="{'setred':i.business || i.business1}" v-model='i.lowerBrokerageBusiness' @blur='getTest(i)' @change='getchange(i)'/><span>&nbsp;%</span>
							</div>
							</div>
						</td>
						<td class="setc">
							<div>
							<span class="spanset">{{item.upperRewardBusiness}}%</span>
							<div class="setH">
								<input type="text" class="inputset" v-bind:class="{'setred':item.business || item.business2}" v-model='item.lowerRewardBusiness' @blur='getTest(item)' @change='getchange(item)'/><span>&nbsp;%</span>
							</div>
							<div class="setH" v-for='i in item.extends' v-if='item.extends.length != 0'>
								<input type="text" class="inputset" v-bind:class="{'setred':i.business || i.business2}" v-model='i.lowerRewardBusiness' @blur='getTest(i)' @change='getchange(i)'/><span>&nbsp;%</span>
							</div>
							</div>
						</td>
						<td class="setc">
							<a @click='setNew(item.policyId)'>编辑</a>
							<a @click='toDetail()'>查看详情</a>
						</td>
					</tr>
					<tr>
						<td colspan="7" style="text-align: center;padding:10px 0;"><span class="addN" @click='toEdit()'>+&nbsp;新建政策</span></td>
					</tr>
				</table>
			</div>
			<div class="p-btn">
				<el-button size='mini' class='wd100 setborder' @click='toUp()'>上一步</el-button>
				<el-button size='mini' type='primary' class='wd100' @click='toNext()'>下一步</el-button>
			</div>
			<el-dialog title="编辑下游政策" :visible.sync="isshow" width="550px" :close-on-click-modal='false'>
			<div class="content">
				<el-form :model="json" :rules="rules" ref="json">
					<el-form-item label="添加对象类型:" :label-width="formLabelWidth" prop="extendType">
						<el-select class="inputs" v-model="json.extendType" size="mini" placeholder="请选择部门">
							<el-option v-for="item in objtypelist" :label="item.name" :value="item.value"></el-option>
						</el-select>
					</el-form-item>

					<!--<el-form-item label="添加对象:" :label-width="formLabelWidth" prop="">
				      <el-select class="inputs" v-model="json.region" size="mini" placeholder="请选择对象">
				        <el-option v-for="item in addobj" label="区域一" value="shanghai"></el-option>
				      </el-select>
				    </el-form-item>-->

					<el-form-item label="添加对象" :label-width="formLabelWidth" prop="targetId">
						<treeSelect v-if="json.extendType==1" :treeData="treeData" :treeProps="treeProps" v-model="json.targetId " :multiple="true" placeholder="请选择对象" @setSelectedId="setSelectedId">
						</treeSelect>

						<el-select v-else class="inputs" multiple v-model="json.targetId" size="mini" placeholder="请选择对象">
							<el-option v-for="item in userlist"  :label="item.userName" :value="item.id"></el-option>
						</el-select>
					</el-form-item>

					<el-form-item label="保费类型:" :label-width="formLabelWidth" prop="premiumType">
						<el-select class="inputs" v-model="json.premiumType" size="mini" placeholder="请选择保费类型">
							<el-option v-for="item in premiumlist" :label="item.name" :value="item.value"></el-option>
						</el-select>
					</el-form-item>

					<el-form-item label="返佣类型:" :label-width="formLabelWidth" prop="brokerageBusinessType">
						<el-select class="inputs" v-model="json.brokerageBusinessType" size="mini" placeholder="请选择返佣类型">
							<el-option v-for="item in Maidlist" :label="item.name" :value="item.value"></el-option>
						</el-select>
					</el-form-item>

					<el-form-item label="是否扣点:" :label-width="formLabelWidth" prop="points">
						<el-select class="inputs" v-model="json.points" size="mini" placeholder="请选择是否扣点">
							<el-option v-for="item in Pointslist" :label="item.name" :value="item.value"></el-option>
						</el-select>
					</el-form-item>

					<el-form-item label="交强险设置:" :label-width="formLabelWidth">
						<div class="numcontent" :class="indexs==1?'actives':''">
							佣金
							<el-input @blur="blurs1" class="numinp" v-model="json.lowerBrokerageTraffic" size="mini"></el-input>
							<span> {{json.brokerageBusinessType  | isPercentage}}</span> 奖励
							<el-input @blur="blurs2" class="numinp" v-model="json.lowerRewardTraffic" size="mini"></el-input>
							<span> {{json.brokerageBusinessType  | isPercentage}}</span>
						</div>
					</el-form-item>

					<el-form-item label="商业险设置:" :label-width="formLabelWidth">
						<div class="numcontent" :class="indexs==2?'actives':''">
							佣金
							<el-input @blur="blurs3" class="numinp" v-model="json.lowerBrokerageBusiness" size="mini"></el-input>
							<span> {{json.brokerageBusinessType  | isPercentage}}</span> 奖励
							<el-input @blur="blurs4" class="numinp" v-model="json.lowerRewardBusiness" size="mini"></el-input>
							<span> {{json.brokerageBusinessType  | isPercentage}}</span>
						</div>
					</el-form-item>

					<!-- <el-form-item label="车船税设置:" :label-width="formLabelWidth" prop="">
						<div class="numcontent">
							佣金
							<el-input @blur="blurs5" class="numinp" v-model="json.lowerBrokerageVehicleTax" size="mini"></el-input>
							<span> {{json.brokerageBusinessType  | isPercentage}}</span>
						</div>
					</el-form-item> -->

					<!-- <el-form-item label="备注信息:" :label-width="formLabelWidth">
						<el-input class="inputs" type="textarea" :rows="2" placeholder="请填写备注信息" v-model="json.remarks">
						</el-input>
					</el-form-item> -->
					<el-form-item class="btn">
						<el-button type="primary" @click.stop="submits('json')">确 定</el-button>
					</el-form-item>
				</el-form>
			</div>
		</el-dialog>
		</div>
	</div>
</template>
<script>
import 	Vue from "vue"
import nextnav from './assembly/nextnav'
import treeSelect from "@/components/tree-select/tree.vue";
	export default{
		data(){
			return{
				id:null,  //当前id
				policylist:[],
				info:null,
				navnum:2,
				dialogShow:false,
				//dialog
				isshow: false,
				formLabelWidth: '120px',
				objtypelist: [ //对象列表
					//					{name:"政策",value:"0"},
					{
						name: "组织",
						value: "1"
					},
					{
						name: "用户",
						value: "2"
					}
				],
				premiumlist: [ //保费列表
					{
						name: "按净保费",
						value: "1"
					},
					{
						name: "按全保费",
						value: "0"
					}
				],
				Maidlist: [ //保费列表
					{
						name: "百分比",
						value: "0"
					},
					{
						name: "人名币",
						value: "1"
					}
				],
				Pointslist: [ //扣点
					{
						name: "是",
						value: "1"
					},
					{
						name: "否",
						value: "0"
					}
				],
				addobj: [ //添加对象列表

				],
				rules: {
					extendType: [{
						required: true,
						message: '请选择对象类型',
						trigger: 'change'
					}],
					targetId : [{
						required: true,
						message: '请选择对象',
						trigger: 'change'
					}],
					premiumType: [{
						required: true,
						message: '请选择保费类型',
						trigger: 'change'
					}],
					brokerageBusinessType : [{
						required: true,
						message: '请选择返佣类型',
						trigger: 'change'
					}],
					points: [{
						required: true,
						message: '请选择是否扣点',
						trigger: 'change'
					}]

				},
				json: {
					policyItemId :"", //政策id
					extendType: "", //对象类型,
					targetId : null, //对象
					premiumType: "1", //保费类型
					brokerageBusinessType : "0", //返佣类型
					points:"0", //是否扣点
					lowerBrokerageTraffic: "0", //交强-佣金
					lowerRewardTraffic: "0", //较强——奖励
					lowerBrokerageBusiness: "0", //商业-佣金
					lowerRewardBusiness: "0", //商业——奖励
					lowerBrokerageVehicleTax: "0", //下游车船税佣金比例
				//	remarks: "" //备注

				},
				userlist: [],
				indexs: null,
				treeData: [], //树数据
				treeProps: {
					label: "displayName",
					children: "orgs",
					level: "depth",
					value: 'id'
				}, //树属性
			}
		},
		mounted(){
			 console.log(this.$route.query.batchId);
			 if(this.$route.query.batchId){
			 	this.id = this.$route.query.batchId;
			 	this.getBasic();
			 	this.getPolicyList();
			 }
			//this.getBasic();
			//this.getPolicyList();
		},
		filters: {
			isPercentage(val) {
				if(val == 0) {
					return "%"
				} else {
					return "元"
				}
			}
		},
		components:{
			nextnav,
			treeSelect
		},
		methods:{
			//信息
			getBasic(){
				let params = {
//					'id':'AFE5BBB3-9E30-46D2-9166-03316C65092D'
					 id:this.id
				}
				this.post(params,'services/app/policy/GetPolicyBatchBasic').then(rs => {
					if(rs.success){
						console.log("success")
						 console.log(rs.result);
						this.info = rs.result;
					}
				})
			},
			//信息表
			getPolicyList(){
				let params = {
					//'id':'AFE5BBB3-9E30-46D2-9166-03316C65092D'
					 id:this.id
				}
				this.post(params,'services/app/policy/GetAllPolicyList').then(rs => {
					if(rs.success){
						console.log(rs.result.items);
						this.policylist = rs.result.items;
						let re = /^[0-9]+.?[0-9]*/;
						this.policylist.forEach(item => {
							if(item){
								for(var i in item){
									if(re.test(item[i])){
										if(item[i] == 0){
											item[i] = '';
										}
									}
									if(i == 'upperBrokerageTraffic'){
										item[i] = item[i]+'';
										if(item[i] == ''){
											item[i] = '0';
										}
									}
									if(i == 'upperRewardTraffic'){
										item[i] = item[i]+'';
										if(item[i] == ''){
											item[i] = '0';
										}
									}
									if(i == 'upperBrokerageBusiness'){
										item[i] = item[i]+'';
										if(item[i] == ''){
											item[i] = '0';
										}
									}
									if(i == 'upperRewardBusiness'){
										item[i] = item[i]+'';
										if(item[i] == ''){
											item[i] = '0';
										}
									}
									if(i == 'lowerBrokerageTraffic'){
										item[i] = item[i]+'';
									}
									if(i == 'lowerRewardTraffic'){
										item[i] = item[i]+'';
									}
									if(i == 'lowerBrokerageBusiness'){
										item[i] = item[i]+'';
									}
									if(i == 'lowerRewardBusiness'){
										item[i] = item[i]+'';
									}
									if(item['extends']){
										item['extends'].forEach(ins => {
										if(ins){
											for(var j in ins){
												if(re.test(ins[j])){
													if(ins[j] == 0){
														ins[j] = '';
													}
												}
												if(j == 'lowerBrokerageTraffic'){
													ins[j] = ins[j]+'';
												}
												if(j == 'lowerRewardTraffic'){
													ins[j] = ins[j]+'';
												}
												if(j == 'lowerBrokerageBusiness'){
													ins[j] = ins[j]+'';
												}
												if(j == 'lowerRewardBusiness'){
													ins[j] = ins[j]+'';
												}
											}
										}
									})
									}
								}
							}
						})
					}
				})
			},
			//两位小数
			twoBit(value){
				if(value){
					console.log(value);
					value = value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符  
				    value = value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的  
				    value = value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
				    value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数  
				    if(value.indexOf(".")< 0 && value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额 
				        value= parseFloat(value); 
				    }
				    // value = value;
				    return value
				}
			},
			//验证小数
			getTest(item){
				console.log(item);
				const that = this;
				// let re = /^[0-9\.]+$/g;          
				let re2 = /^\d+(\.\d{1,2})?$/;
				for(let i in item){
					if(i == 'lowerBrokerageTraffic' || i == 'lowerRewardTraffic' || i == 'lowerBrokerageBusiness' || i == 'lowerRewardBusiness'){
						if(!re2.test(item[i])){
							Vue.set(item,i,that.twoBit(item[i]))
							this.getchange(item);
							// console.warn(item[i]);
						}
					}
				}
			},
			//验证100
			getchange(item){
				console.log(item);
				const that = this;
				let re = /^[0-9]+.?[0-9]*/;
				for(var i in item){
					if(item[i] === ''){
						item[i] = '0';
					}
					if(re.test(item[i])){
						if(i == 'lowerBrokerageTraffic'){
							if(Number(item[i])+Number(item['lowerRewardTraffic']) > 100){
								Vue.set(item,'traffic',true)
							}else{
								Vue.set(item,'traffic',false)
							}
							if(Number(item[i])>100){
								Vue.set(item,'traffic1',true)
							}else{
								Vue.set(item,'traffic1',false)
							}
						}
						if(i == 'lowerRewardTraffic'){
							if(Number(item[i])+Number(item['lowerBrokerageTraffic'])  > 100){
								Vue.set(item,'traffic',true)
							}else{
								Vue.set(item,'traffic',false)
							}
							if(Number(item[i])>100){
								Vue.set(item,'traffic2',true)
							}else{
								Vue.set(item,'traffic2',false)
							}
						}
						if(i == 'lowerBrokerageBusiness'){
							if(Number(item[i])+Number(item['lowerRewardBusiness']) > 100){
								Vue.set(item,'business',true)
							}else{
								Vue.set(item,'business',false)
							}
							if(Number(item[i])>100){
								Vue.set(item,'business1',true)
							}else{
								Vue.set(item,'business1',false)
							}
						}
						if(i == 'lowerRewardBusiness'){
							if(Number(item[i])+Number(item['lowerBrokerageBusiness']) > 100){
								Vue.set(item,'business',true)
							}else{
								Vue.set(item,'business',false)
							}
							if(Number(item[i])>100){
								Vue.set(item,'business2',true)
							}else{
								Vue.set(item,'business2',false)
							}
						}
					}
				}
			},
			//遍历，空为0
			eachArr4(arr){
				let re = /^[0-9]+.?[0-9]*/;
				arr.forEach(item => {
					if(item){
						for(var i in item){
							if(re.test(item[i])){
								if(item[i] == ''){
									item[i] = '0';
								}
							}
							if(i == 'upperBrokerageTraffic' && item['upperBrokerageTraffic'] == ''){
								item[i] = '0';
								console.log(item[i]);
							}
							if(i == 'upperRewardTraffic' && item['upperRewardTraffic'] == ''){
								item[i] = '0';
							}
							if(i == 'upperBrokerageBusiness' && item['upperBrokerageBusiness'] == ''){
								item[i] = '0';
							}
							if(i == 'upperRewardBusiness' && item['upperRewardBusiness'] == ''){
								item[i] = '0';
							}
							if(i == 'lowerBrokerageTraffic' && item['lowerBrokerageTraffic'] == ''){
								item[i] = '0';
							}
							if(i == 'lowerRewardTraffic' && item['lowerRewardTraffic'] == ''){
								item[i] = '0';
							}
							if(i == 'lowerBrokerageBusiness' && item['lowerBrokerageBusiness'] == ''){
								item[i] = '0';
							}
							if(i == 'lowerRewardBusiness' && item['lowerRewardBusiness'] == ''){
								item[i] = '0';
							}
							if(item['extends']){
								item['extends'].forEach(ins => {
								if(ins){
									for(var j in ins){
										if(re.test(ins[j])){
											if(ins[j] == 0){
												ins[j] = '';
											}
										}
										if(j == 'lowerBrokerageTraffic' && item['lowerBrokerageTraffic'] == ''){
											ins[j] = '0';
										}
										if(j == 'lowerRewardTraffic' && item['lowerRewardTraffic'] == ''){
											ins[j] = '0';
										}
										if(j == 'lowerBrokerageBusiness' && item['lowerBrokerageBusiness'] == ''){
											ins[j] = '0';
										}
										if(j == 'lowerRewardBusiness' && item['lowerRewardBusiness'] == ''){
											ins[j] = '0';
										}
									}
								}
							})
							}
						}
					}
				})
				return arr;
			},
			//下一步
			toNext(){
				console.log(this.policylist);
				if(this.policylist.length == 0){
					this.$message({
						type:'warning',
						message:'请新建政策'
					})
				}else{
				const that = this;
				let obj = [];
				obj = this.policylist;
				new Promise(function(resolve,reject){
				for(let i=0;i<obj.length;i++){
					// console.log(i);
					for(let j in obj[i]){
						if(obj[i]['traffic'] === true || obj[i]['traffic1'] === true || obj[i]['traffic2'] === true || obj[i]['business'] === true || obj[i]['business1'] === true || obj[i]['business2'] === true) {
							console.warn(j);
							reject();
						}else{
							if(obj[i][j] === false){
								delete obj[i][j]
							}
						}
						if(j == 'extends'){
							for(let ex=0;ex<obj[i]['extends'].length;ex++){
								// console.log(obj[i]['extends'][ex]);
								for(let s in obj[i]['extends'][ex]){
									// console.log(obj[i]['extends'][ex][s])
									if(obj[i]['extends'][ex]['traffic'] === true || obj[i]['extends'][ex]['traffic1'] === true || obj[i]['extends'][ex]['traffic2'] === true || obj[i]['extends'][ex]['business'] === true || obj[i]['extends'][ex]['business1'] === true || obj[i]['extends'][ex]['business2'] === true) {
										console.warn(ex);
										reject();
									}else{
										if(obj[i]['extends'][ex][s] === false){
											delete obj[i]['extends'][ex][s]
										}
									}
								}
							}
						}
					}
				}
				resolve(obj);

			}).then(obj => {
				let arr = that.eachArr4(obj);
				// console.log(arr);
				return arr;
			}).then(arr => {
				console.warn(arr);
				let params={
						items:arr
					}
					console.log(params);
					this.post(params,'services/app/policy/UpdateLowerPolicyCustom').then(rs => {
						if(rs.success){
							this.$router.push({
							 	name:"policylower4",
							 	query:{
							 		batchId:this.id
							 	}
							})
							console.log('----------------------')
						}else{
							// console.log(this.policylist);
							console.log(rs.result.state);
							console.log(rs.result.errorMessage);
						}
					})
				},()=>{
					console.log('信息填写错误');
					this.$message({
						type:'warning',
						message:'信息填写错误'
					})
				})
			}
			},
			//上一步
			toUp(){
				this.$router.push({
					name:"policydownnew2",
					query:{
						batchId:this.id
					}
				})
			},
			//详情
			toDetail(){
				this.$router.push({
					name:"policyupnewdd",
					query:{
						batchId:this.id,
						filterType:1
					}
				})
			},
			toEdit(){
				this.$router.push({
					name:"policyupnewdd",
					query:{
						batchId:this.id
					}
				})
			},
			//编辑
			setNew(id){
				this.json.policyItemId = id;
				this.isshow = true;
				this.getUnits()
				this.getuesr()
			},
			//----------------------dialog
			//用户信息
			getuesr() {
				let params = {};
				this.post(params, "services/app/common/GetUsers").then(
					rs => {
						console.log(rs);
						if(rs.success) {
							console.log('success')
							console.log(rs)
							this.userlist = rs.result.users
						}
					}
				);
			},
			//组织机构
			getUnits() {
				let params = {};
				this.post(params, "services/app/common/GetCurrentOrganizationUnits").then(
					rs => {
						console.log(rs);
						if(rs.success) {
							let data = rs.result;
							let arr = [];
							arr.push(data);
							this.treeData = arr;
							// console.log(rs.result);
							// console.log(this.treeData);
							// console.log('-----------');
						}
					}
				);
			},
			//tree
			setSelectedId(val) {
				console.log(val);
				this.json.targetId  = val;
			},
			blurs1(val) {
				let aa = this.clearNoNum(val.target.value)
				Vue.set(this.json, "lowerBrokerageTraffic", aa)
			},
			blurs2(val) {
				let aa = this.clearNoNum(val.target.value)
				Vue.set(this.json, "lowerRewardTraffic", aa)
			},
			blurs3(val) {
				let aa = this.clearNoNum(val.target.value)
				Vue.set(this.json, "lowerBrokerageBusiness", aa)
			},
			blurs4(val) {
				let aa = this.clearNoNum(val.target.value)
				Vue.set(this.json, "lowerRewardBusiness", aa)
			},
			blurs5(val) {
				let aa = this.clearNoNum(val.target.value)
				Vue.set(this.json, "lowerBrokerageVehicleTax", aa)
			},
			clearNoNum(obj) {
				obj = obj.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
				obj = obj.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
				obj = obj.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
				obj = obj.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数
				if(obj.indexOf(".") < 0 && obj != "") {
					//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
					obj = parseFloat(obj);
				}
				if(obj >= 100) {
					obj = 100
				}
				if(obj == "") {
					obj = 0
				}
				console.log(obj)
				return obj

			},
			submits(formName) {
				let a1 = parseFloat(this.json.lowerBrokerageTraffic)
				let a2 = parseFloat(this.json.lowerRewardTraffic)
				let b1 = parseFloat(this.json.lowerBrokerageBusiness)
				let b2 = parseFloat(this.json.lowerRewardBusiness)
				this.$refs[formName].validate((valid) => {
					if(valid) {
						if(a1 + a2 > 100 || b1 + b1 > 100) {
							if(a1 + a2 > 100) {
								this.indexs = 1
							} else {
								this.indexs = 2
							}

						} else {
							this.indexs = null
							console.log(this.json)
							this.json.targetId=this.json.targetId.join(",")
							let arr = [];
							arr.push(this.json);
							let params={
								"extends":arr
							}
					      	this.post(params, "services/app/policy/PolicyAddExtendInfo").then(rs => {
						        console.log(rs)
						        this.getBasic();
								this.getPolicyList();
						      });
							this.isshow=false
						}

					} else {
						console.log('error submit!!');
						return false;
					}
				});
			}
		}
	}
</script>
<style lang='scss' scoped>
.content {
	width: 100%;
	height:500px;
	overflow:auto;
	font-size: 12px;
}

.inputs {
	width: 250px;
	font-size: 12px;
}

.numinp {
	width: 60px;
	margin-left: 5px;
}

.numcontent {}

.btn {
	display: flex;
	justify-content: center;
}

.actives .numinp {
	border: 1px solid #f56c6c;
}
/*#f56c6c*/

.rh {
	float: right;
	height: 28px;
	span {
		display: inline-block;
		width: 80px;
	}
	selectone {
		display: inline-block;
	}
	.util-select {
		width: 190px;
	}
}
/*---------------------------------*/

.wd100{
	width:100px;
	height: 32px;
}
.setH{
	line-height:40px;height:40px;
	border-bottom:1px solid #e8e8e8;
}
.setH:last-child{
	border-bottom: 0;
}
.app-container{
	.policyupper3c{
		padding:0 68px 0 68px;
		.p-detail{
			margin-top:50px;
			p{
				font-size:14px;
				color:#333;
				margin:20px 0;
				.add{
					font-size: 10px;
					color:#fff;
					background: #ff9430;
					border-radius: 8px;
					width:30px;
					height: 15px;
					display: inline-block;
					text-align: center;
					margin-left: 10px;
					transform:scale(0.9)
				}
			}
			.d-box{
				background:#eaf5fb;
				//width: 100%;
				height:79px;
				padding:15px 30px;
				p{
					margin:0;
					span{
						font-size:12px;
						color:#95bacc;
					}
					.d-setc{
						color: #2e94c5;
					}
					.isF:first-child{
						display:none;
					}
				}
				p:nth-of-type(1){
					margin-bottom: 16px;
				}
			}
		}
		.p-list{
			//width:100%;
			.util-table{
				//width:100%;
				height:80px;
				border:0;
				//border-bottom:1px solid #e8e8e8;
				border-collapse:collapse;
				tr{
					th{
						background:#334750;
						color:#fff;
						border:0;
						text-align: center;
					}
					td{
						//padding:10px 0;
						font-size:14px;
						border-bottom:double #e8e8e8;
						.inputset{
							background:#e8e8e8;
							border:1px solid #c3c1c1;
							width:45px;
							height:21px;
							text-align: right;
							color:#333333;
							font-size:12px;
							padding:3px;
						}
						span{
							font-size:13px;
						}
						.setred{
							border:1px solid #ff0000;
						}
						a{
							color:#027dca;
							font-size:13px;
						}
						.addN{
							font-size: 14px;
							color: #027DCA;
							cursor: pointer;
						}
					}
					.setc{
						text-align: center;
						padding:0;
						.spanset{
							display:block;
							line-height: 40px;
							height:40px;
							text-align: center;
							color:#333333;
							border-bottom:1px solid #e8e8e8;
						}
						.setg{
							color:#019F6C;
							font-size:12px;
							line-height: 40px;
							height:40px;
							min-width: 100px;
							display:block;
							border-bottom:1px solid #e8e8e8;
							span{
								color:#019F6C;
								font-size:12px;
							}
						}
						.setg:last-child{border-bottom: 0;}
						.setr{
							color:#FF0000;
							font-size:12px;
							line-height: 40px;
							height:40px;
							display:block;
							border-bottom:1px solid #e8e8e8;
						}
					}
				}
			}
		}
		.p-btn{
			text-align: center;
			margin:20px 0;
			.setborder{
				background: #F7F7F7;
				border: 1px solid #DDDDDD;
				font-size: 14px;
				color: #666666;
			}
		}
	}
}
</style>